package net.xiangcaowuyu.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import net.xiangcaowuyu.springcloud.entites.CommonResult;
import net.xiangcaowuyu.springcloud.entites.Payment;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * 博客：https://www.xiangcaowuyu.net
 * Description:
 *
 * @Author: 香草物语
 * DateTime: 2021-07-24 13:15
 */
@RestController
@RequestMapping("/consumer")
@Slf4j
public class OrderController {

    private final static String PAYMENT_URL = "http://192.168.120.180:8001";

    @Resource
    private RestTemplate restTemplate;

    @PostMapping("/payment/create")
    public CommonResult create(Payment payment) {
        return restTemplate.postForObject(PAYMENT_URL + "/payment/create", payment, CommonResult.class);
    }

    @GetMapping("/payment/get/{id}")
    public CommonResult get(@PathVariable("id") Long id) {
        return restTemplate.getForObject(PAYMENT_URL + "/payment/get/" + id, CommonResult.class);
    }

}
